package com.micro.service.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Create by Vic Xu on 2019/3/6
 */
@Configuration
@EnableWebMvc
public class WebConfiguration implements WebMvcConfigurer {

//    跨域配置
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedOrigins("http://localhost:8082")  //可配置多个URL
                .allowedMethods("GET", "PUT", "POST", "DELETE")
                .allowCredentials(true)
                .maxAge(3600);
    }

}
